Skip to content

Drop the period citeproc-php adds after a "?" or "!" title - #155

Merged
dknauss merged 3 commits into
mainfrom
fix/chicago-terminal-punctuation
Oct 19, 2026
Merged

dknauss merged 3 commits into
mainfrom
fix/chicago-terminal-punctuation

Conversation

@dknauss

@dknauss dknauss commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Problem

The server formatter (citeproc-php, behind bibliography_builder_format_csl_items() and bibliography_builder_write_prepare_entries()) puts a period inside the closing quote after a title that already ends in ? or !:

  • webpage: “What Are Reduced Penetrance and Variable Expressivity?.” MedlinePlus. …
  • article-journal: Moss, Ann. “Diabetes Technology: What’s New in 2025?.” Diabetes Care 48 …

CMOS wants “…?” with no added period. The 2026-10-14 cmt.blog citation pass hit this on three Sources entries (posts 94341, 3766, 606), which were corrected by hand.

Cause

The stray period comes from citeproc-php itself, not from the plugin's en-US "move the period inside the quotes" swap. Rendering a ? title raw with Chicago gives “What Is It?.”: citeproc-php moves the title's . suffix inside the quote without checking for terminal punctuation. It affects every style that quotes titles and ends the title with a period: Chicago notes-bibliography, Chicago author-date and MLA 9. APA, Harvard, IEEE, Vancouver, OSCOLA and ABNT were already correct.

Fix

bibliography_builder_normalize_formatted_text() now removes a period that follows ? or !, with or without a closing ”/’. Commas are left alone: CMOS keeps a comma after a question-mark title (“Are You a Doctor?,”), and IEEE's “…?,” is unchanged.

Tests (test-first)

  • New CslStyleGoldenTest::test_title_ending_in_question_or_exclamation_mark_takes_no_period. It covers a webpage and an article-journal ending in ? and a webpage ending in !, with exact expected strings for Chicago notes-bibliography and MLA 9. It also asserts that no bundled style emits ?./!.. Before the fix it failed with the ?.” output above.
  • The existing CSL style goldens pass byte for byte. No tests/fixtures/csl-styles/*.txt file changed, because the corpus has no ?/! titles, so the CMOS 18 et-al. output (first three authors + et al. for 7+) is untouched.
  • Full PHP suite: 447 tests passing. phpcs is clean on the changed files.

Editor (citeproc-js) path

The editor has no client-side citeproc. src/lib/formatting/csl.js posts the CSL items to the plugin's format REST endpoint, which uses this same PHP formatter, so the fix applies in the editor too. citeproc-js (citeproc 2.4.63) is only a dev dependency, used by src/lib/__test-utils__/citeproc-runner.js for sort conformance. I ran the same three items through it with the packaged Chicago NB, Chicago AD and MLA styles. It already renders “…Expressivity?” MedlinePlus. …, “…What’s New in 2025?” Diabetes Care 48 (2025): 1–10. and “Stop the Presses!” Site. …, and the PHP output now matches it character for character.

Not covered

Bibliographies saved earlier keep the stored ?.” text until they are reformatted or saved again.

🤖 Generated with Claude Code

dknauss and others added 3 commits October 14, 2026 22:38
citeproc-php moves a title's "." suffix inside the closing quote without
checking for terminal punctuation, so Chicago (both styles) and MLA
rendered "What Is It?.”". Strip a period that follows "?" or "!" (with
or without a closing quote) in the formatter's text normalization.
Commas are kept, as CMOS allows after a question-mark title.

citeproc-js already renders these titles correctly; the server output
now matches it. Existing style goldens are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o match the repositoryines

Updated line counts for main plugin file and first-party PHP.Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1qSnyqMzCKxQbVdnTpoVX
@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.28%. Comparing base (ad56433) to head (f40c90a).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #155   +/-   ##
=========================================
  Coverage     88.28%   88.28%           
  Complexity       22       22           
=========================================
  Files            61       61           
  Lines          7290     7291    +1     
  Branches        690      690           
=========================================
+ Hits           6436     6437    +1     
  Misses          291      291           
  Partials        563      563           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dknauss
dknauss merged commit 1c66ecb into main Oct 19, 2026
19 checks passed
@dknauss
dknauss deleted the fix/chicago-terminal-punctuation branch October 19, 2026 21:33
@dknauss dknauss mentioned this pull request Oct 22, 2026
4 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant